// .txt

beginzonescript;

variables;

short crime_tolerance = 200;
short last_abil;
short i;
short set_att = 0;

body;

beginstate INIT_STATE;

//	set_name(,"");

	add_range_to_group(8,11,1);
	add_range_to_group(31,34,2);

	add_range_to_group(20,24,3);
	set_resistance(1003,1,25);
	
	set_aggression(14,7);
	set_aggression(15,7);
	set_aggression(16,7);
	set_aggression(17,7);
	set_walk_speed(14,24);
	set_walk_speed(15,24);
	set_walk_speed(16,24);
	set_walk_speed(17,24);
	
	set_aggression(25,8);
	set_aggression(26,8);
	set_aggression(27,8);
	set_aggression(28,8);
	set_aggression(29,8);
	set_aggression(30,8);
	set_level(25,20);
	set_level(26,20);
	set_level(27,20);
	set_level(28,20);
	set_level(29,20);
	set_level(30,20);
	
	set_level(35,20);
	set_level(36,20);
	set_name(37,"Rune-Etched Golem");
	set_boss_level(37,1);
	set_new_abil(37,12);
	
	//if (get_sdf() > 0) {
		//make_zone_hostile();
		//}

	if (gf(34,22) == 1)
		sf(34,22,0);
		
	last_abil = get_current_tick();
	
	set_crime_tolerance(crime_tolerance);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	// clear zone?
	if ((zone_clear(ME) == FALSE) && (get_flag(36,1) > 0)) {
		clear_zone(ME);	
		}
		
	//if ((get_crime_level() >= crime_tolerance) && (get_sdf(,) == 0)) {
	//	make_zone_hostile();
	//	set_flag(,,1);
	//	}

	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(1001,"Whirrrr ...");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(1001,"Click. Click.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(1001,"Hmmmmmmm ...");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(1002,"Whirrrr ...");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(1002,"Click. Click.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(1002,"Hmmmmmmm ...");

	
	if ((gf(36,22) > 0) && (num_chars_in_group(3) > 0) && (set_att == 0)) {
		set_attitude(1003,10);
		set_att = 1;
		}
		
	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 4))) {
		last_abil = get_current_tick();
		
		if (gf(34,22) == 1) {
			if (gf(34,23) > 0)
				inc_flag(34,23,-1);
			if (gf(34,24) > 0) {
				inc_flag(34,24,-1);
				if (gf(34,24) == 1)	
					print_str_color("The northern conduit is approaching maximum power.",3);
				if (gf(34,24) == 0)	{
					print_str_color("The machine in the center of the room starts spitting out sparks and",3);
					print_str_color("  smoke where the north conduit enters it.",3);
					}
				}
			if (gf(34,25) > 0) {
				inc_flag(34,25,-1);
				if (gf(34,25) == 1)	
					print_str_color("The southern conduit is approaching maximum power.",3);
				if (gf(34,25) == 0)	{
					print_str_color("The machine in the center of the room starts spitting out sparks and",3);
					print_str_color("  smoke where the south conduit enters it.",3);
					}
				}
			if (gf(34,26) > 0) {
				inc_flag(34,26,-1);
			
				if (gf(34,26) == 6) {
					begin_talk_mode(17);
					}
				if (gf(34,26) == 1) 
					print_str_color("The western door is almost open.",3);
				if (gf(34,26) == 0) {
					set_attitude(1003,10);
					give_object_message(70,DOOR_OPEN_MESSAGE);
					begin_talk_mode(22);
					}
				}
			

			}
		}
	
	if ((party_near_nav(2,10)) && (gf(34,22) == 0))
		begin_talk_mode(16);
break;

//beginstate 10;
//break;

//	print_str("");
//	set_terrain_string_range(".",3);
//	set_terrain_string_range("The sign says - .",3);
